/* ====================================
   模态框样式模块 (modal.css)
   专门用于模态框组件，避免样式冲突
   ==================================== */

/* 基础模态框类 - 兼容HTML中的.modal类名 */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    backdrop-filter: blur(4px) !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    animation: modalFadeIn 0.3s ease-out !important;
}

/* 模态框遮罩层 */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    backdrop-filter: blur(4px) !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    animation: modalFadeIn 0.3s ease-out !important;
}

/* 主策略编辑模态框 - 基础层级 */
.modal,
.modal-overlay {
    z-index: 9999 !important;
}

/* 区域选择器模态框 - 更高层级 */
.modal.area-selector-modal,
.modal-overlay.area-selector-modal {
    z-index: 19999 !important; /* 比主弹框更高 */
    background: rgba(0, 0, 0, 0.8) !important; /* 更深的背景 */
}

/* V3区域选择器模态框 - 最高层级 */
.v3-area-selector-modal,
.modal .v3-area-selector-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.8) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 29999 !important; /* 比所有弹框都高 */
    backdrop-filter: blur(6px) !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    animation: modalFadeIn 0.3s ease-out !important;
}

/* 策略编辑模态框特定层级 */
#strategy-edit-modal.modal-overlay,
.v3-strategy-edit-modal {
    z-index: 9999 !important;
}

/* 模态框容器 */
.modal-container,
.modal .modal-content,
.strategy-edit-modal {
    background: white !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25) !important;
    width: 95vw !important;
    max-width: 1400px !important;
    height: 90vh !important;
    max-height: 90vh !important;
    min-height: 600px !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 auto !important;
    padding: 0 !important;
    transform: none !important;
    position: relative !important;
    border: 2px solid var(--color-primary) !important;
    animation: modalSlideIn 0.3s ease-out !important;
}

/* 模态框头部 */
.modal-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 20px 24px !important;
    border-bottom: 1px solid var(--color-border-lighter) !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    flex-shrink: 0 !important;
    border-radius: 16px 16px 0 0 !important;
}

.modal-header h2 {
    font-size: 18px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: white !important;
    flex: 1 !important;
}

.modal-header h3,
.modal-header .modal-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: white !important;
    flex: 1 !important;
}

.close-btn {
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    padding: 8px !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s !important;
    outline: none !important;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.1) !important;
}

.modal-close {
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    padding: 8px !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s !important;
    outline: none !important;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.1) !important;
}

.modal-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5) !important;
    outline-offset: 2px !important;
}

/* 模态框内容区域 */
.modal-content {
    flex: 1 !important;
    padding: 20px !important;
    overflow-y: auto !important;
    background: #f8f9fa !important;
    max-height: calc(90vh - 160px) !important;
    margin: 0 !important;
    border: none !important;
}

/* 针对.modal > .modal-content的特殊处理 */
.modal > .modal-content {
    background: white !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25) !important;
    width: 95vw !important;
    max-width: 1400px !important;
    height: auto !important;
    max-height: 90vh !important;
    min-height: 300px !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 auto !important;
    padding: 0 !important;
    transform: none !important;
    position: relative !important;
    border: 2px solid var(--color-primary) !important;
    animation: modalSlideIn 0.3s ease-out !important;
}

/* 针对.modal > .modal-content的内容重新定义 */
.modal > .modal-content > form,
.modal > .modal-content > .modal-body {
    flex: 1 !important;
    padding: 20px !important;
    overflow-y: auto !important;
    background: #f8f9fa !important;
    max-height: calc(90vh - 160px) !important;
}

/* 模态框底部 */
.modal-footer {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 12px !important;
    padding: 20px 24px !important;
    border-top: 1px solid var(--color-border-lighter) !important;
    background: var(--color-background-lighter) !important;
    flex-shrink: 0 !important;
    border-radius: 0 0 16px 16px !important;
}

/* 模态框内的表单和内容样式 */
.modal-content .form-group {
    margin-bottom: 1rem !important;
}

.modal-content .form-label {
    display: block !important;
    margin-bottom: 0.5rem !important;
    font-weight: 500 !important;
    color: var(--color-text-primary) !important;
}

.modal-content .form-input,
.modal-content .form-select,
.modal-content .form-textarea {
    width: 100% !important;
    padding: 0.5rem 0.75rem !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--border-radius-md) !important;
    font-size: 14px !important;
    background: white !important;
}

.modal-content .form-input:focus,
.modal-content .form-select:focus,
.modal-content .form-textarea:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2) !important;
    outline: none !important;
}

/* 策略编辑模态框特定样式 */
.strategy-info-display {
    margin-bottom: 32px !important;
    padding: 20px !important;
    background: white !important;
    border-radius: 12px !important;
    border: 1px solid var(--color-border-lighter) !important;
    box-shadow: var(--box-shadow-sm) !important;
}

.info-card {
    background: white !important;
    padding: 20px !important;
    border-radius: 8px !important;
    box-shadow: var(--box-shadow-sm) !important;
}

.info-card h4 {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--color-text-primary) !important;
    margin-bottom: 16px !important;
    padding-bottom: 8px !important;
    border-bottom: 2px solid var(--color-primary) !important;
}

.info-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
}

.info-item {
    display: flex !important;
    align-items: center !important;
}

.info-item .label {
    font-weight: 500 !important;
    color: var(--color-text-regular) !important;
    margin-right: 8px !important;
}

.info-item .value {
    color: var(--color-text-primary) !important;
}

/* 配置区域样式 */
.config-section {
    margin-bottom: 24px !important;
    background: white !important;
    border-radius: 8px !important;
    padding: 20px !important;
    box-shadow: var(--box-shadow-sm) !important;
    border: 1px solid var(--color-border-extra-light) !important;
}

.section-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 16px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid var(--color-border-extra-light) !important;
}

.section-header h3 {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--color-text-primary) !important;
    margin: 0 !important;
}

/* 配置表格样式 */
.config-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 12px !important;
    background: white !important;
}

.config-table th,
.config-table td {
    border: 1px solid var(--color-border-lighter) !important;
    padding: 8px 12px !important;
    text-align: left !important;
    font-size: 12px !important;
}

.config-table th {
    background: var(--color-background-lighter) !important;
    font-weight: 600 !important;
    color: var(--color-text-primary) !important;
}

.config-table tbody tr:hover {
    background-color: var(--color-background-light) !important;
}

/* 空状态样式 */
.empty-state {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 60px 20px !important;
    color: var(--color-text-secondary) !important;
    font-size: 16px !important;
    text-align: center !important;
}

.empty-state::before {
    content: '📋' !important;
    font-size: 48px !important;
    margin-bottom: 12px !important;
    opacity: 0.6 !important;
}

.empty-state p {
    margin: 10px 0 !important;
}

.empty-cell {
    text-align: center !important;
    padding: 40px !important;
}

/* 模态框动画 */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===============================
   V3区域选择器模态框专用样式
   优先级最高，避免与styles.css冲突
   =============================== */

/* V3区域选择器容器 */
.v3-area-selector-modal .modal-content {
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
    width: 90vw !important;
    max-width: 1000px !important;
    max-height: 85vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 auto !important;
    padding: 0 !important;
    position: relative !important;
    border: 2px solid #409eff !important;
    animation: modalSlideIn 0.3s ease-out !important;
}

/* V3区域选择器内容区 */
.v3-area-selector-content {
    flex: 1 !important;
    padding: 20px !important;
    overflow: auto !important;
    background: #fafbfc !important;
}

/* V3三级联动面板 */
.v3-cascader-panel {
    display: flex !important;
    gap: 0 !important;
    min-height: 400px !important;
    border: 1px solid #e6e8eb !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    background: white !important;
    margin-bottom: 20px !important;
}

/* V3三级联动列 */
.v3-cascader-column {
    flex: 1 !important;
    min-width: 250px !important;
    border-right: 1px solid #e6e8eb !important;
    display: flex !important;
    flex-direction: column !important;
    background: white !important;
}

.v3-cascader-column:last-child {
    border-right: none !important;
}

/* V3三级联动头部 */
.v3-cascader-header {
    background: #f8f9fa !important;
    border-bottom: 1px solid #e6e8eb !important;
    padding: 12px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    color: #333 !important;
    flex-shrink: 0 !important;
}

/* V3三级联动选项容器 */
.v3-cascader-options {
    flex: 1 !important;
    overflow-y: auto !important;
    max-height: 350px !important;
    background: white !important;
}

/* V3三级联动选项 */
.v3-cascader-option {
    display: flex !important;
    align-items: center !important;
    padding: 10px 16px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
    min-height: 40px !important;
    background: white !important;
}

.v3-cascader-option:hover {
    background: #f0f9ff !important;
}

.v3-cascader-option:last-child {
    border-bottom: none !important;
}

/* V3复选框样式 */
.v3-cascader-option input[type="checkbox"] {
    margin-right: 10px !important;
    cursor: pointer !important;
    width: 16px !important;
    height: 16px !important;
    accent-color: #409eff !important;
}

/* V3选项标签 */
.v3-option-label {
    flex: 1 !important;
    font-size: 14px !important;
    color: #333 !important;
    user-select: none !important;
    cursor: pointer !important;
    line-height: 1.4 !important;
}

/* V3展开按钮 */
.v3-cascader-option .expand-btn {
    background: #409eff !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 12px !important;
    margin-left: 8px !important;
    transition: background-color 0.2s !important;
    flex-shrink: 0 !important;
}

.v3-cascader-option .expand-btn:hover {
    background: #337ecc !important;
}

/* V3选中区域预览 */
.v3-selected-preview {
    margin-top: 20px !important;
    padding: 16px !important;
    background: #f0f9ff !important;
    border: 1px solid #b3d8ff !important;
    border-radius: 8px !important;
}

.v3-selected-preview .preview-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 12px !important;
}

.v3-selected-preview .preview-header h4 {
    margin: 0 !important;
    font-size: 16px !important;
    color: #333 !important;
    font-weight: 600 !important;
}

.v3-selected-preview .selected-count {
    background: #409eff !important;
    color: white !important;
    padding: 4px 12px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}

.v3-selected-preview .selected-summary {
    display: flex !important;
    gap: 16px !important;
    flex-wrap: wrap !important;
}

.v3-selected-preview .selected-summary span {
    background: white !important;
    color: #409eff !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    border: 1px solid #b3d8ff !important;
}

/* V3区域选择器操作按钮 */
.v3-area-selector-actions {
    padding: 16px 20px !important;
    border-top: 1px solid #e6e8eb !important;
    background: #fafbfc !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
}

/* 小按钮样式 */
.btn-tiny {
    padding: 4px 8px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    border-radius: 4px !important;
    min-height: auto !important;
    height: auto !important;
}
@media (max-width: 1400px) {
    .strategy-edit-modal {
        width: 96vw !important;
        max-width: 1200px !important;
    }
}

@media (max-width: 1200px) {
    .strategy-edit-modal {
        width: 95vw !important;
        max-width: 1000px !important;
    }
    
    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}

@media (max-width: 768px) {
    .strategy-edit-modal {
        width: 98vw !important;
        height: 95vh !important;
        max-height: 95vh !important;
    }
    
    .modal-content {
        padding: 16px !important;
        /* 移除高度限制，确保重量区间规则表格能完整显示 */
    }
    
    .modal-header,
    .modal-footer {
        padding: 16px 20px !important;
    }
    
    .section-header {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
    }
    
    .config-table th,
    .config-table td {
        padding: 6px 8px !important;
        font-size: 11px !important;
    }
}

@media (max-width: 480px) {
    .strategy-edit-modal {
        width: 99vw !important;
        height: 98vh !important;
        max-height: 98vh !important;
    }
    
    .modal-content {
        padding: 12px !important;
    }
    
    .modal-header h2 {
        font-size: 16px !important;
    }
    
    .config-table th,
    .config-table td {
        padding: 4px 6px !important;
        font-size: 10px !important;
    }
}